<template>
	<view class="personal-center">
		<!-- 背景设计 -->
		<view class="background-design">
			<view class="gradient-bg"></view>
			<image class="book-pattern" src="/static/images/book-pattern.png" mode="aspectFill"></image>
		</view>
		
		<!-- 用户信息区域 -->
		<view class="user-info-section">
			<view class="welcome-message">
				<text class="greeting">您好，</text>
				<text class="username">{{user.userName}}</text>
			</view>
			
			<view class="user-stats">
				<view class="stat-item" @click="navigateTo('/pages/order/order')">
					<view class="stat-value">{{user.orderCount}}</view>
					<view class="stat-label">已购书籍</view>
				</view>
				<view class="stat-item" @click="navigateTo('/pages/college/college')">
					<view class="stat-value">{{user.collectCount}}</view>
					<view class="stat-label">我的收藏</view>
				</view>
				<view class="stat-item" @click="navigateTo('/pages/shoppingCart/shoppingCart')">
					<view class="stat-value">{{user.cartCount}}</view>
					<view class="stat-label">待读清单</view>
				</view>
			</view>
		</view>
		
		<!-- 功能菜单 -->
		<view class="menu-section">
			<view class="section-title">我的账户</view>
			
			<view class="menu-list">
				<view class="menu-item" @click="navigateTo('/pages/order/order')">
					<uni-icons type="cart" size="22" color="#5E7CE2"></uni-icons>
					<text class="item-text">我的订单</text>
					<uni-icons type="arrowright" size="16" color="#999"></uni-icons>
				</view>
				
				<view class="menu-item" @click="navigateTo('/pages/college/college')">
					<uni-icons type="heart" size="22" color="#FF6B6B"></uni-icons>
					<text class="item-text">我的收藏</text>
					<uni-icons type="arrowright" size="16" color="#999"></uni-icons>
				</view>
				
				<view class="menu-item" @click="navigateTo('/pages/liuyan/liuyan')">
					<uni-icons type="chat" size="22" color="#6BD0A2"></uni-icons>
					<text class="item-text">我的留言</text>
					<uni-icons type="arrowright" size="16" color="#999"></uni-icons>
				</view>
				
			<!-- 	<view class="menu-item" @click="navigateTo('/pages/recommend/recommend')">
					<uni-icons type="star" size="22" color="#FFC107"></uni-icons>
					<text class="item-text">推荐偏好</text>
					<uni-icons type="arrowright" size="16" color="#999"></uni-icons>
				</view> -->
				
				<view class="menu-item" @click="logout">
					<uni-icons type="redo" size="22" color="#9E9E9E"></uni-icons>
					<text class="item-text">退出登录</text>
					<uni-icons type="arrowright" size="16" color="#999"></uni-icons>
				</view>
			</view>
		</view>
		
		<!-- 阅读数据统计 -->
		<view class="reading-stats">
			<view class="stats-title">本月阅读数据</view>
			<view class="stats-content">
				<view class="reading-stat">
					<text class="stat-number">12</text>
					<text class="stat-desc">本已读</text>
				</view>
				<view class="reading-stat">
					<text class="stat-number">36</text>
					<text class="stat-desc">小时阅读</text>
				</view>
				<view class="reading-stat">
					<text class="stat-number">5</text>
					<text class="stat-desc">本在读</text>
				</view>
			</view>
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				user: {
					userName: "书友",
					orderCount: 0,
					collectCount: 0,
					cartCount: 0
				}
			};
		},
		onLoad() {
			const userData = uni.getStorageSync('user') || {};
			this.user = {...this.user, ...userData};
		},
		methods: {
			navigateTo(url) {
				uni.navigateTo({ url });
			},
			logout() {
				uni.showModal({
					title: '提示',
					content: '确定要退出登录吗？',
					success: (res) => {
						if (res.confirm) {
							uni.removeStorageSync('user');
							uni.reLaunch({ url: '/pages/login/login' });
						}
					}
				});
			}
		}
	}
</script>

<style lang="less" scoped>
.personal-center {
	padding-bottom: 40rpx;
	min-height: 100vh;
	background-color: #f8f9fa;
	position: relative;
	
	.background-design {
		position: absolute;
		top: 0;
		left: 0;
		right: 0;
		height: 400rpx;
		overflow: hidden;
		z-index: 0;
		
		.gradient-bg {
			position: absolute;
			top: 0;
			left: 0;
			right: 0;
			height: 100%;
			background: linear-gradient(135deg, #6a11cb 0%, #2575fc 100%);
		}
		
		.book-pattern {
			position: absolute;
			top: 0;
			left: 0;
			width: 100%;
			height: 100%;
			opacity: 0.08;
		}
	}
	
	.user-info-section {
		padding: 40rpx;
		position: relative;
		z-index: 1;
		
		.welcome-message {
			margin-bottom: 60rpx;
			
			.greeting {
				font-size: 40rpx;
				color: rgba(255, 255, 255, 0.9);
				margin-right: 16rpx;
			}
			
			.username {
				font-size: 48rpx;
				color: #fff;
				font-weight: 600;
			}
		}
		
		.user-stats {
			display: flex;
			justify-content: space-between;
			background: #fff;
			border-radius: 20rpx;
			padding: 40rpx 30rpx;
			box-shadow: 0 10rpx 30rpx rgba(0, 0, 0, 0.08);
			
			.stat-item {
				flex: 1;
				text-align: center;
				
				.stat-value {
					font-size: 48rpx;
					font-weight: 600;
					color: #333;
					margin-bottom: 10rpx;
				}
				
				.stat-label {
					font-size: 28rpx;
					color: #666;
				}
			}
		}
	}
	
	.menu-section {
		margin: 30rpx;
		background: #fff;
		border-radius: 20rpx;
		overflow: hidden;
		box-shadow: 0 10rpx 30rpx rgba(0, 0, 0, 0.05);
		position: relative;
		z-index: 1;
		
		.section-title {
			padding: 30rpx;
			font-size: 30rpx;
			color: #999;
			border-bottom: 1rpx solid #f0f0f0;
		}
		
		.menu-list {
			.menu-item {
				display: flex;
				align-items: center;
				padding: 30rpx;
				position: relative;
				
				&:active {
					background-color: #f8f8f8;
				}
				
				.item-text {
					flex: 1;
					margin-left: 30rpx;
					font-size: 32rpx;
					color: #333;
				}
				
				&::after {
					content: '';
					position: absolute;
					left: 90rpx;
					right: 0;
					bottom: 0;
					height: 1rpx;
					background-color: #f0f0f0;
					transform: scaleY(0.5);
				}
				
				&:last-child::after {
					display: none;
				}
			}
		}
	}
	
	.reading-stats {
		margin: 30rpx;
		background: #fff;
		border-radius: 20rpx;
		padding: 30rpx;
		box-shadow: 0 10rpx 30rpx rgba(0, 0, 0, 0.05);
		position: relative;
		z-index: 1;
		
		.stats-title {
			font-size: 30rpx;
			color: #999;
			margin-bottom: 30rpx;
		}
		
		.stats-content {
			display: flex;
			justify-content: space-between;
			
			.reading-stat {
				flex: 1;
				text-align: center;
				
				.stat-number {
					display: block;
					font-size: 48rpx;
					font-weight: 600;
					color: #5E7CE2;
					margin-bottom: 10rpx;
				}
				
				.stat-desc {
					font-size: 28rpx;
					color: #666;
				}
			}
		}
	}
}
</style>